package com.asset.dispoal.business.approval;

import com.asset.dispoal.business.approval.api.RepaymentApproverService;
import com.asset.dispoal.business.approval.dto.ApproverListResponse;
import com.asset.dispoal.business.approval.dto.AuditRequest;
import com.asset.dispoal.business.approval.dto.GetApproverRequest;
import com.asset.dispoal.business.approval.dto.GetRepaymentApprovalListRequest;
import com.asset.dispoal.business.approval.dto.RepaymentApprovalResponse;
import com.asset.dispoal.business.approval.dto.RepaymentApproverBindRequest;
import com.asset.dispoal.business.approval.dto.RepaymentApproverResponse;
import com.asset.dispoal.business.approval.dto.RepaymentDetailResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import tech.mhuang.pacebox.springboot.protocol.Result;
import tech.mhuang.pacebox.springboot.protocol.data.PageVO;

/**
 * @description:
 * @author: yf
 * @date: 2022-10-08 10:18:48
 */
@RestController
@RequestMapping("business/approval")
@Api(value = "还款审核管理", tags = "还款审核管理")
public class RepaymentApproveController {
    @Autowired
    private RepaymentApproverService repaymentApproverService;

    @PostMapping("/approver")
    @ApiOperation(value = "审核人信息获取接口", notes = "审核人信息获取接口")
    public Result<PageVO<ApproverListResponse>> approverList(@RequestBody GetApproverRequest request) {
        return repaymentApproverService.getApprover(request);
    }

    @PostMapping("/bindRepayment")
    @ApiOperation(value = "还款审核人绑定接口", notes = "还款审核人绑定接口")
    public Result bindRepayment(@RequestBody RepaymentApproverBindRequest request) {
        repaymentApproverService.bind(request);
        //根据当前登录人获取
        return Result.ok();
    }

    @GetMapping("/getBindApprover")
    @ApiOperation(value = "还款审核人获取接口", notes = "还款审核人获取接口")
    public Result<RepaymentApproverResponse> getBindApprover(String assetInstBatchId) {
        return repaymentApproverService.getBindApprover(assetInstBatchId);
    }

    @PostMapping("/getApprovalList")
    @ApiOperation(value = "获取还款审核列表接口", notes = "获取还款审核列表接口")
    public Result<PageVO<RepaymentApprovalResponse>> getRepaymentApproveList(@RequestBody GetRepaymentApprovalListRequest request) {
        return repaymentApproverService.getApprovalList(request);
    }

    @PostMapping("/audit")
    @ApiOperation(value = "审核接口", notes = "审核接口 1：通过 2:不通过")
    public Result audit(@RequestBody AuditRequest request) {
        repaymentApproverService.audit(request);
        return Result.ok();
    }

    @GetMapping("/detail")
    @ApiOperation(value = "还款详情接口", notes = "还款详情接口")
    public Result<RepaymentDetailResponse> detail(String repaymentLogId) {
        RepaymentDetailResponse response = repaymentApproverService.getApprovalDetail(repaymentLogId);
        return Result.ok(response);
    }

    @PostMapping("/myRepaymentList")
    @ApiOperation(value = "我的还款列表接口", notes = "我的还款列表接口")
    public Result<PageVO<RepaymentApprovalResponse>> myRepaymentList(@RequestBody GetRepaymentApprovalListRequest request) {
        return repaymentApproverService.getMyRepaymentList(request);
    }

}
